package android.FiltrosJava;

public class SaturationCorrection extends PointFilter{
	protected int numIterations = 7;
	
	public SaturationCorrection(int iterations){
		setIterations(iterations);				
	}
	public void setIterations(int iterations){
		numIterations = iterations;
		if (numIterations < 1)
			numIterations = 1;
	}
	public int[] computeFilter(int px, int py, int[] imageData){
		int cmaxi, cmini, somme;
		for (int k = 0; k < numIterations; k++){
			cmaxi = (int) Math.max(imageData[0],Math.max(imageData[1],imageData[2]));
			cmini = (int) Math.min(imageData[0],Math.min(imageData[1],imageData[2]));			
			somme = (int) ((cmaxi + cmini) /2);							
			
			for ( int y = 0; y < 3; y++ ) {
				imageData[y] = delimitaCor((int) (imageData[y] + (((imageData[y] - somme)*40.0f)/256.0f)));				
			}			
		}
		
		return imageData;
	}
	@Override
	public int[] applyFilter(int[] pixels) {
		// TODO Auto-generated method stub
		return null;
	}
}